package ext.tianma.part;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 同步成品IBA属性接口
 * @author deng
 *
 */
@Controller
@RequestMapping({ "/PLMSynchronousPart" })
public class PLMSynchronousPartController {
/**
 * 同步成品IBA属性接口
 * @param productNumber  成品编号
 * @param view 成品视图
 * @param projectNumber 项目编号
 * @param projectName 项目名称
 * @param projectManager 项目经理
 * @param response
 * @throws Exception
 */
	@RequestMapping(value = "/synchronousPart", method = {RequestMethod.POST, RequestMethod.GET })
	public void synchronousPart(
			@RequestParam(value = "productNumber", required = true) String productNumber,
			@RequestParam(value = "view", required = true) String view,
			@RequestParam(value = "projectNumber", required = true) String projectNumber,
			@RequestParam(value = "projectName", required = true) String projectName,
			@RequestParam(value = "projectManager", required = true) String projectManager,
			HttpServletResponse response) throws Exception {
		boolean enforce = wt.session.SessionServerHelper.manager
				.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html;charset=UTF-8");
		try {
			String result = PLMSynchronousPartService.synchronousPartMessage(productNumber,view,projectNumber,projectName,projectManager);
			out.print(result);
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
			wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}
	/**
	 * 清空成品项目编号，项目名称，项目经理IBA属性
	 * 
	 * @param productNumber 成品编号
	 * @param view 视图
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/emptyPartIBA", method = {RequestMethod.POST, RequestMethod.GET })
	public void emptyPartIBA(
			@RequestParam(value = "productNumber", required = true) String productNumber,
			@RequestParam(value = "view", required = true) String view,
			HttpServletResponse response) throws Exception {
		boolean enforce = wt.session.SessionServerHelper.manager
				.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html;charset=UTF-8");
		try {
			String result = PLMSynchronousPartService.emptyPartIBA(productNumber,view);
			out.print(result);
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
			wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}
}
